-
Notifications
You must be signed in to change notification settings - Fork 740
feat: add async public key support #5473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goatgoose
reviewed
Aug 25, 2025
goatgoose
reviewed
Aug 27, 2025
goatgoose
reviewed
Sep 2, 2025
lrstewart
reviewed
Sep 3, 2025
lrstewart
reviewed
Sep 3, 2025
lrstewart
reviewed
Sep 4, 2025
goatgoose
reviewed
Sep 9, 2025
lrstewart
reviewed
Sep 10, 2025
lrstewart
reviewed
Sep 10, 2025
lrstewart
reviewed
Sep 11, 2025
lrstewart
approved these changes
Sep 12, 2025
goatgoose
reviewed
Sep 12, 2025
goatgoose
approved these changes
Sep 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Release Summary:
Adds async public key support:
s2n_pkey_verify()
can be performed asynchronously through the async offloading callback.Description of changes:
To improve the performance of CPU-expensive operations such as
s2n_pkey_verify()
, this PR implements a generic async callback to offload handshake operations that do not require user input. To execute in the async mode, applications should spawn a separate thread to invokes2n_async_offload_op_perform()
and return success from the async offloading callback directly.Since this async callback is expected to support more operation types in the future, we added an allow list field for users to explicitly declare the operations they want to offload. This eliminates the risk of breaking existing users when we add support for a new op type later.
Below is an overview of the code changes:
s2n_async_offload_cb
and relevant data types.s2n_async_offload_op_perform()
function to perform the operation and update async status. If this function is invoked inside the offloading callback, it is equivalent to the synchronous use case.s2n_config_set_async_offload_callback()
for users to configure their callback and the type of operations they want to execute in async mode. By default, no operation type is async.s2n_pkey_verify()
withs2n_async_pkey_verify()
to support the async functionality.s2n_pkey_verify()
was invoked bys2n_server_key_recv()
ands2n_client_cert_verify_recv()
in TLS 1.2, as well ass2n_tls13_cert_verify_recv()
in TLS 1.3.s2n_async_pkey_verify()
to incorporate the re-entry logic based on the value ofasync_offload_op.async_state
.Call-outs:
To prevent users from accessing invalid memory accidentally, the
s2n_async_offload_cb
object is allocated on stack (ins2n_connection
) rather than on heap. This increased the connection size by ~100 bytes and caused thes2n_connection_size_test
to fail in the CI FreeBSD job:I updated
max_connection_size
to 4360. Open to other suggestions.Testing:
Added a unit test for this feature and confirmed it passed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.